package com.seo.textgen.spacer;

public class Spacer {

	private static final boolean[][] MATRIX = new boolean[SpacerTokenType.LAST][SpacerTokenType.LAST];

	static {
		setSpace(SpacerTokenType.WORD, SpacerTokenType.SPACE_AROUND_PUNKT);
		setSpace(SpacerTokenType.SPACE_AROUND_PUNKT, SpacerTokenType.WORD);
		setSpace(SpacerTokenType.WORD, SpacerTokenType.WORD);
		setSpace(SpacerTokenType.PUNKT, SpacerTokenType.WORD);
		setSpace(SpacerTokenType.WORD, SpacerTokenType.LEFT_BRACKET);
		setSpace(SpacerTokenType.RIGHT_BRACKET, SpacerTokenType.WORD);
	}

	private static void setSpace(byte tokenType1, byte tokenType2) {
		MATRIX[tokenType1][tokenType2] = true;
	}

	public static boolean haveSpaceBetween(byte tokenType1, byte tokenType2) {
		return MATRIX[tokenType1][tokenType2];
	}
	
	public static boolean haveSpaceBetween(String token1, String token2) {
		return MATRIX[SpacerTokenTypeClassifier.getSpacerTokenType(token1)][SpacerTokenTypeClassifier.getSpacerTokenType(token2)];
	}
}
